package Rangel.common.convex;

import com.poths.rna.data.Point;

import java.awt.*;
import java.util.List;

public class ConvexHull {

    com.poths.rna.data.ConvexHull convexHull = new com.poths.rna.data.ConvexHull();

    public void addPoint(int x, int y) {
        convexHull.addPoint(new com.poths.rna.data.Point(x, y));
    }

    public Polygon convex() {
        List<Point> pointList = convexHull.getPointList();
        int[] xPoints2 = new int[pointList.size()];
        int[] yPoints2 = new int[pointList.size()];

        for (int i = 0; i < pointList.size(); i++) {
            xPoints2[i] = (int) pointList.get(i).getX();
            yPoints2[i] = (int) pointList.get(i).getY();
        }

        return new Polygon(xPoints2, yPoints2, pointList.size());
    }
}
